package top.kaoshanji.r2ch07a;

/**
 * 代码清单-r2ch07a-217页a：一个被性能监控和事务管理包围的业务逻辑方法示例
 * @author kaoshanji
 * ^_^
 * create time 2025/5/7 10:41
 */
public class ForumService {

    private TransactionManager transManager;
    private PerformanceMonitor monitor;
    private TopicDao topicDao;
    private ForumDao forumDao;

    public void removeTopic(int topicId) {
        monitor.start();
        transManager.beginTransaction();

        topicDao.removeTopic(topicId);

        transManager.endTransaction();
        monitor.end();
    }

    public void createForum(Forum forum) {
        monitor.start();
        transManager.beginTransaction();

        forumDao.create(forum);

        transManager.endTransaction();
        monitor.end();

    }

}
